﻿/// <reference path="scroll.d.ts" />
import ko = require("knockout");

class ScrollHandler {
    static create() {
        ko.bindingHandlers.scrollTop = {
            init: (element, valueAccessor) => {
                /*element.addEventListener("scroll", (event) => {
                    valueAccessor()(element.scrollTop);
                });*/
            },
            update: (element, valueAccessor) => {
                element.scrollTop = ko.unwrap(valueAccessor());
                element.ignoreScroll = true;
            }
        };

        ko.bindingHandlers.scrollLeft = {
            init: (element, valueAccessor) => {
                /*element.addEventListener("scroll", (event) => {
                    valueAccessor()(element.scrollTop);
                });*/
            },
            update: (element, valueAccessor) => {
                element.scrollLeft = ko.unwrap(valueAccessor());
                element.ignoreScroll = true;
            }
        };
    }
}

export = ScrollHandler;